package com.probiz.estore.common.model.product.base;

import java.io.Serializable;
import com.probiz.estore.Constants;
import com.probiz.estore.core.model.BaseObject;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;

/**
 * SearchByAttr Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class SearchByAttrTbl extends BaseObject implements Serializable {

    protected Integer searchByAttrId;
	protected Integer sortOrder;
	protected Short showStyle;
	protected String searchValue;
	protected com.probiz.estore.common.model.product.ProductType productType;
	protected com.probiz.estore.common.model.attribute.Attribute attribute;


	/**
	 * Default Empty Constructor for class SearchByAttr
	 */
	public SearchByAttrTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class SearchByAttr
	 */
	public SearchByAttrTbl (
		 Integer in_searchByAttrId
        ) {
		this.setSearchByAttrId(in_searchByAttrId);
    }

	
	public com.probiz.estore.common.model.product.ProductType getProductType () {
		return productType;
	}	
	
	public void setProductType (com.probiz.estore.common.model.product.ProductType in_productType) {
		this.productType = in_productType;
	}
	
	public com.probiz.estore.common.model.attribute.Attribute getAttribute () {
		return attribute;
	}	
	
	public void setAttribute (com.probiz.estore.common.model.attribute.Attribute in_attribute) {
		this.attribute = in_attribute;
	}
    

	/**
	 * 	 * @return Integer
     * @hibernate.id column="searchByAttrId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getSearchByAttrId() {
		return this.searchByAttrId;
	}
	
	/**
	 * Set the searchByAttrId
	 */	
	public void setSearchByAttrId(Integer aValue) {
		this.searchByAttrId = aValue;
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getProductTypeId() {
		return this.getProductType()==null?null:this.getProductType().getProductTypeId();
	}
	
	/**
	 * Set the productTypeId
	 */	
	public void setProductTypeId(Integer aValue) {
	    if (aValue==null) {
	    	productType = null;
	    } else {
	        productType = new com.probiz.estore.common.model.product.ProductType(aValue);
	        productType.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getAttributeId() {
		return this.getAttribute()==null?null:this.getAttribute().getAttributeId();
	}
	
	/**
	 * Set the attributeId
	 */	
	public void setAttributeId(Integer aValue) {
	    if (aValue==null) {
	    	attribute = null;
	    } else {
	        attribute = new com.probiz.estore.common.model.attribute.Attribute(aValue);
	        attribute.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * 	 * @return Short
	 * @hibernate.property column="showStyle" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getShowStyle() {
		return this.showStyle;
	}
	
	/**
	 * Set the showStyle
	 * @spring.validator type="required"
	 */	
	public void setShowStyle(Short aValue) {
		this.showStyle = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="searchValue" type="java.lang.String" length="512" not-null="true" unique="false"
	 */
	public String getSearchValue() {
		return this.searchValue;
	}
	
	/**
	 * Set the searchValue
	 * @spring.validator type="required"
	 */	
	public void setSearchValue(String aValue) {
		this.searchValue = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof SearchByAttrTbl)) {
			return false;
		}
		SearchByAttrTbl rhs = (SearchByAttrTbl) object;
		return new EqualsBuilder()
				.append(this.searchByAttrId, rhs.searchByAttrId)
								.append(this.sortOrder, rhs.sortOrder)
				.append(this.showStyle, rhs.showStyle)
				.append(this.searchValue, rhs.searchValue)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.searchByAttrId) 
								.append(this.sortOrder) 
				.append(this.showStyle) 
				.append(this.searchValue) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("searchByAttrId", this.searchByAttrId) 
								.append("sortOrder", this.sortOrder) 
				.append("showStyle", this.showStyle) 
				.append("searchValue", this.searchValue) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "searchByAttrId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return searchByAttrId;
	}

}